package com.hidt.shop.mapper;

import com.hidt.shop.domain.Browse;
import com.hidt.shop.domain.CollectionAndGoods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrowseMapper {
    /**
     * 添加浏览记录
     *@参数  browse
     *@返回值  int
     *@创建人  lmf
     *@创建时间  2021/1/21
     */
    @Insert("insert into browse (id,good_id) values(#{id},#{good_id})")
    int AddBrowse(Browse browse);

    /**
     * 通过会员id删除浏览商品id的记录
     *@参数  browse
     *@返回值  int
     *@创建人  lmf
     *@创建时间  2021/1/21
     */
    @Delete("delete from browse where good_id=#{good_id} and id=#{id}")
    int DeleteBrowseById(Browse browse);

    /**
     * 通过会员id查看浏览记录
     *@参数  id
     *@返回值  List<CollectionAndGoods>
     *@创建人  lmf
     *@创建时间  2021/1/21
     */
    @Select("select goods.good_name,goods.good_picture,goods.good_id,goods.goodsale_price,goods_discount from browse,goods where id=#{id} and goods.good_id=browse.good_id and goods.goodis_delete=0")
    List<CollectionAndGoods> FindAllBrowseById(int id);
}
